home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / msjv6-5.zip / WINDOS.ZIP / ARGCARGV.C next >
C/C++ Source or Header  |  1991-09-01  |  1KB  |  63 lines

  1. /* 
  2. argcargv.c -- see MSJ, May 1991, pp. 135-136
  3.  
  4. bcc -WS -G -O -Z -c -w-par winio.c wmhandlr.c argcargv.c
  5. bcc -WS -G -O -Z -c %1.c
  6. tlink f:\borlandc\lib\c0ws %1 argcargv winio wmhandlr,%1/c/x/Tw,null,import \
  7.     cwins maths cs;
  8. rc winio.res %1.exe
  9. */
  10.  
  11. #include "windows.h"
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include "winio.h"
  15.  
  16. #ifdef __BORLANDC__
  17. // Borland must have followed (incorrect) doc in SDK Guide, p. 14-3
  18. #define argc _argc
  19. #define argv _argv
  20.  
  21. extern int _argc;
  22. extern char **_argv;
  23. #else
  24. // Microsoft C code per MSJ, May 1991, pp. 135-6
  25. #define argc __argc
  26. #define argv __argv
  27.  
  28. extern int __argc;
  29. extern char **__argv;
  30. #endif
  31.  
  32. extern int main(int argc, char **argv, char **envp);
  33.  
  34. HANDLE _hinst;
  35. HANDLE _hprevinst;
  36. LPSTR _lpcmdline;
  37. int _ncmdshow;
  38.  
  39. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, 
  40.     LPSTR lpCmdLine, int nCmdShow)
  41. {
  42.     char title[256];
  43.     
  44.     _hinst= hInstance;
  45.     _hprevinst = hPrevInstance;
  46.     _lpcmdline = lpCmdLine;
  47.     _ncmdshow = nCmdShow;
  48.     
  49.     /* set up application's title bar */
  50.     GetModuleFileName(hInstance, title, 256);
  51.     if (lpCmdLine && *lpCmdLine)
  52.     {
  53.         _fstrcat(title, " ");
  54.         _fstrcat(title, lpCmdLine);
  55.     }
  56.     winio_settitle(title);
  57.     
  58.     if (! winio_init(hInstance, hPrevInstance, nCmdShow, 0))
  59.         return 1;
  60.     
  61.     return main(argc, argv, environ);
  62. }
  63.